<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>点击函数案例</title>
</head>

<head>
    <script>
        function changetext(id) {
            id.innerHTML = "Ooops!";
        }
    </script>

</head>

<body>

    <!-- 点击文本执行输出 -->
    <h1 onclick="changetext(this)">点击文本!</h1>

    <!-- 点击文本执行输出 -->
    <h2 onclick="this.innerHTML='Ooops!'">点击文本!</h2>

    <!-- 点击按钮执行函数 -->
    <button onclick="displayDate()" id="demo">点这里</button>
    <script>
        function displayDate() {
            document.getElementById("demo").innerHTML = Date();
        }
    </script>
</body>

</html>